Function.prototype.extractComment = (function () {
    var startComment = "/*!";
    var endComment = "*/";

    return function () {
        var str = this.toString();
        var start = str.indexOf(startComment);
        var end = str.lastIndexOf(endComment);
        return str.slice(start + startComment.length, -(str.length - end));
    };
})();


String.prototype.capitalize = function () {
    return this.charAt(0).toUpperCase() + this.slice(1);
};
String.prototype.format = function () {
    var objects = arguments;

    return this.replace(/\{([^}]+)\}/g, (function () {
        function parseGroupValue(groupValue) {
            var index = groupValue.indexOf(':');
            return {
                method: (index > 0) ? groupValue.substr(index + 1, groupValue.length - index) : null,
                variableName: (index > 0) ? groupValue.substr(0, index) : groupValue
            };
        }

        return function (group, groupValue) {
            var result = null;
            var settings = parseGroupValue(groupValue);
            for (var i = 0; i < objects.length; i++) {
                var obj = objects[i];
                if (obj[settings.variableName] != null) {
                    result = obj[settings.variableName];
                } else if (obj['get_' + settings.variableName] != null) {
                    result = obj['get_' + settings.variableName]();
                }
                if (result) break;
            }
            if (settings.method) {
                result = window[settings.method](result);
            }
            return result;
        };
    })());
};